/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DataAccess;

import javax.swing.table.TableModel;

/**
 *
 * @author thangvv0907i
 */
public class SalesManagerFunction_DA {

    
    public TableModel modelViewBillsCancel_DA() {
        SetTableModel rtm = new SetTableModel();
        String query="select Count(*) as [Bills Canceled] from Bills where Status=0";
        try {
            rtm.setHostURL(ConnectionDB.getConnectionString());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        rtm.setQuery(query);
        return rtm;
    }

    public TableModel modelViewBills_DA() {
        SetTableModel rtm = new SetTableModel();
        String query="select Count(*) as [Bills Created] from Bills";
        try {
            rtm.setHostURL(ConnectionDB.getConnectionString());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        rtm.setQuery(query);
        return rtm;
    }

    public TableModel modelViewMoney() {
         SetTableModel rtm = new SetTableModel();
        String query="select sum(Total) as [Money paid] from Bills where Status=1";
        try {
            rtm.setHostURL(ConnectionDB.getConnectionString());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        rtm.setQuery(query);
        return rtm;
    }

    public TableModel modelViewItemsNotAvariable() {
        SetTableModel rtm = new SetTableModel();
        String query="select * from Items where I_QUantity < 0";
        try {
            rtm.setHostURL(ConnectionDB.getConnectionString());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        rtm.setQuery(query);
        return rtm;
    }

    public TableModel modelViewItemsCancel() {
        SetTableModel rtm = new SetTableModel();
        String query="select sum(bd.Quantity) as [Quantity Items Returned] from BillDetails bd inner join Bills b on b.B_ID=bd.B_ID where b.Status=0";
        try {
            rtm.setHostURL(ConnectionDB.getConnectionString());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        rtm.setQuery(query);
        return rtm;
    }

}
